#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
typedef struct {
    Queue q1;
    Queue q2;
} MyStack;
MyStack* myStackCreate() {
    MyStack* ps = (MyStack*)malloc(sizeof(MyStack));
    QueueInit(&(ps->q1));
    QueueInit(&(ps->q2));
    return ps;
}

void myStackPush(MyStack* obj, int x) {
    if (!QueueEmpty(&(obj->q1)))
    {
        QueuePush(&(obj->q1), x);
    }
    else
    {
        QueuePush(&(obj->q2), x);
    }
}
int myStackPop(MyStack* obj) {
    Queue* empty = &(obj->q1);
    Queue* noempty = &(obj->q2);
    if (QueueEmpty(&(obj->q1)) != true)
    {
        empty = &(obj->q2);
        noempty = &(obj->q1);
    }
    while (QueueSize(noempty) > 1)
    {
        QueuePush(empty, QueueFront(noempty));
        QueuePop(noempty);
    }
    int top = QueueFront(noempty);
    QueuePop(noempty);
    return top;
}

int myStackTop(MyStack* obj) {
    if (QueueEmpty(&(obj->q1)) != true)
    {
        return QueueBack(&(obj->q1));
    }
    else
    {
        return QueueBack(&(obj->q2));
    }
}
bool myStackEmpty(MyStack* obj) {
    return QueueEmpty(&(obj->q1)) && QueueEmpty(&(obj->q2));
}

void myStackFree(MyStack* obj) {
    QueueDestroy(&(obj->q1));
    QueueDestroy(&(obj->q2));
    free(obj);
}
int main()
{
	return 0;
}